package api;

import domain.CertificateHelper;
import domain.GenCertiInput;
import domain.SecretHelper;

public class SecurityService {
    CertificateHelper certificateHelper;
    SecretHelper secretHelper;
    public void genCerticate(CertificateHelper certificateHelper) {
        this.certificateHelper=certificateHelper;
        secretHelper=new SecretHelper(certificateHelper);
    }

    public void genCertificate(GenCertiInput input) throws Exception {
        certificateHelper.genCertificate(input);
    }


    public String getBase64PublicKey(String name, String keyPsw ) throws Exception{
        String base64PublicKey=certificateHelper.getStrPublicKey(name,keyPsw);
        return base64PublicKey;
    }

    public String getBase64PrivateKey(String name, String keyPsw ) throws Exception{
        String base64PrivateKey=certificateHelper.getStrPrivateKey(name,keyPsw);
        return base64PrivateKey;
    }

    public String encrypt(String orgStr,String name,String keyPsw) throws Exception {
        String encriptedStr=secretHelper.decrypt(orgStr,name,keyPsw);
        return encriptedStr;
    }
    public  String decrypt(String encrypedStr, String name,String keyPsw  ) throws Exception{
        String encriptedStr=secretHelper.decrypt(encrypedStr,name,keyPsw);
        return encriptedStr;
    }


}
